unit Class_FILT;

interface
uses
  Classes,SysUtils;

type
  TBillFilt=class(TObject)
  public
    SeatStax:Integer;
    SeatEndx:Integer;
    BoolSeat:Boolean;

    QuitStax:Integer;
    QuitEndx:Integer;
    BoolQuit:Boolean;

    SickName:string;
    SickMemo:string;
    BillCode:string;

    DoctIdex:string;//in 
    WorkIdex:string;//in
  public
    function  ExpSQL:string;
  public
    constructor Create;
  end;

  TKjqjFilt=class(TObject)
  public
    BillKJQJ:Integer;
    DoctIdex:Integer;
  public
    constructor Create;
  end;


  TDaysFilt=class(TObject)
  public
    DaysStaX:Integer;
    DaysEndX:Integer;
    DoctIdex:Integer;
  public
    constructor Create;
  end;

implementation

{ TKjqjFilt }

constructor TKjqjFilt.Create;
begin
  DoctIdex:=-1;
end;

{ TDaysFilt }

constructor TDaysFilt.Create;
begin
  DoctIdex:=-1;
end;

{ TBillFilt }

constructor TBillFilt.Create;
begin
  DoctIdex:='';
  WorkIdex:='';
end;

function TBillFilt.ExpSQL: string;
begin
  Result:='SELECT * FROM TBL_BILL WHERE 1=1';

  if BoolSeat then
  begin
    Result:=Result + '    AND   SEAT_TIME >=%D   AND  SEAT_TIME <=%D';
    Result:=Format(Result,[SeatStax,SeatEndx]);
  end;

  if BoolQuit then
  begin
    Result:=Result + '    AND   QUIT_TIME >=%D   AND  QUIT_TIME <=%D';
    Result:=Format(Result,[QuitStax,QuitEndx]);  
  end;

  if WorkIdex<>'' then
  begin
    Result:=Result+'     AND WORK_IDEX IN (%S)';
    Result:=Format(Result,[WorkIdex]);
  end;

  if DoctIdex<>'' then
  begin
    Result:=Result+'     AND DOCT_IDEX IN (%S)';
    Result:=Format(Result,[DoctIdex]);
  end;

  if SickName<>'' then
  begin
    Result:=Result +'    AND  SICK_NAME  LIKE  '+QuotedStr('%'+SickName+'%');
  end;

  if BillCode<>'' then
  begin
    Result:=Result +'    AND  BILL_CODE  LIKE  '+QuotedStr('%'+BILLCODE+'%');
  end;

  Result:=Result   +'    ORDER  BY BILL_IDEX';
end;

end.
